import * as types from './../constants/ActionTypes';

/*
 * 用户信息
 ================================================================*/
export function fetchUser() {
  return  (dispatch) => {
  	
  	let payload = {
        user_status: 0,
        message: '加载中'
    };

    dispatch({
      payload, 
      type: [types.FETCH_USER, types.FETCH_USER_SUCCESS, types.FETCH_USER_FAILURE],
      meta: {
        fetch: [`member/info`, {method: 'get'}]
      }  
    });
  };
};

/*
 * 更新用户信息
 ================================================================*/
export function updateUserInfo(key, value){
  return (dispatch) => {
      let payload = {
          update_userinfo_status: 0,
          message: '加载中',
          key : key, 
          value : value
      };
      
      dispatch({
          payload,
          type : types.UPDATE_USER_INFO
      });
  };
}


/*
 * 用户信息 - 复位
 ================================================================*/
export function resetUser(){
  return (dispatch) => {

        let payload = null;
        
        dispatch({
            payload,
            type : types.RESET_USER_INFO
        });
    };
}